package cn.iocoder.yudao.framework.validation;

import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

/**
 * @author 山野羡民
 * @since 2025/09/06
 */
public class DiscountValidator implements ConstraintValidator<Discount, Number> {

    @Override
    public boolean isValid(Number value, ConstraintValidatorContext context) {
        // 如果输入为空，默认不校验，即校验通过
        if (value == null) {
            return true;
        }
        // 校验是折扣范围
        return cn.hutool.core.lang.Validator.isBetween(value, 0, 10);
    }

}
